/***************************************************************************
创建者：华磊
 开始时间：               : 2020.1１.09
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   右侧视窗对话框
*                                                                         *
 ***************************************************************************/
#include "rightview.h"
#include "ui_rightview.h"

RightView::RightView(int styleId,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::RightView)
{
    ui->setupUi(this);

    setGeometry(rect().x()+525, rect().y()+120,70, 430);
    initialDisplayStyle(styleId);

    pushButton.append(ui->BtUpAndDown);
    pushButton.append(ui->BtSwingArm);
    pushButton.append(ui->BtbeforeAndAfter);
    pushButton.append(ui->BtRotating);
    pushButton.append(ui->BtFlip);
    pushButton.append(ui->BtEmpty);


    buttonText.resize(D_ROBOT_AXIS_MAX);
    buttonPictureAddress.resize(D_ROBOT_AXIS_MAX);

    //先初始 高亮 第一个轴
    buttonPictureAddress[0]="/agvwork/AgvHmi/baseBag/hmiProject/resources/rightviewresources/right_empty_p.png";
    pushButton[0]->setStyleSheet(QString("border-image: url(%1);").arg(buttonPictureAddress[0]));
}

RightView::~RightView()
{
    delete ui;
}

 void RightView::initialDisplayStyle(int styleId)
 {
     switch (styleId) {
     case 1:
         ui->BtSwingArm->setGeometry(15,101,51,46);
         ui->BtbeforeAndAfter->setGeometry(15,172,51,46);
         ui->BtRotating->setGeometry(15,243,51,46);
         ui->BtFlip->setGeometry(15,314,51,46);
         ui->BtEmpty->setGeometry(15,384,51,46);
         //ui->Bt_7->setGeometry(15,390,51,46);

         break;
     default:
         break;
     }
 }

void RightView::on_BtUpAndDown_clicked()
{
    emit button1Signal();
}

void RightView::on_BtSwingArm_clicked()
{
    emit button2Signal();
}

void RightView::on_BtbeforeAndAfter_clicked()
{
    emit button3Signal();
}

void RightView::on_BtRotating_clicked()
{
    emit button4Signal();
}

void RightView::on_BtFlip_clicked()
{
    emit button5Signal();
}

void RightView::on_BtEmpty_clicked()
{
    emit button6Signal();
}

void RightView:: changeJogAxisName(bool isJointShow, int totalAxisCountIn, int pageIdIn, int onePageMaxAxisCount)
{
    if(isJointShow)
    {
        for(int i = 0;i<6;i++)
        {

            if(i<totalAxisCountIn-pageIdIn*onePageMaxAxisCount )
            {
                pushButton[i]->setEnabled(true);
                pushButton[i]->setText("J"+QString::number(i+1+pageIdIn*onePageMaxAxisCount));
            }
            else
            {
                pushButton[i]->setEnabled(false);
            }

        }
    }
    else
    {
        for(int i = 0;i<6;i++)
        {
            if(i<6)
                pushButton[i]->setEnabled(true);
            else
                pushButton[i]->setEnabled(false);

        }
        pushButton[0]->setText("X");
        pushButton[1]->setText("Y");
        pushButton[2]->setText("Z");
        pushButton[3]->setText("W");
        pushButton[4]->setText("P");
        pushButton[5]->setText("R");
    }


}

//void RightView::setCurrentAxis(int count)
//{
//    if(count>=0 && count<pushButton.size())
//    {
//        pushButton[count]->setStyleSheet(QString("border-image: url(%1);").arg(buttonPictureAddress[count]));
//    }
//}

void RightView::updateView()
{
    if(pushButton.size() == buttonPictureAddress.size() )
    {
        for(int i = 0;i<pushButton.size();i++)
        {
            pushButton[i]->setStyleSheet(QString("border-image: url(%1);").arg(buttonPictureAddress[i]));
        }
    }
    else
    {
        return;
    }
}
